package com.capgemini.scaffold.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.capgemini.scaffold.dto.HomePage;
import com.capgemini.scaffold.entity.Dict;
import com.capgemini.scaffold.entity.User;
import com.capgemini.scaffold.mapper.DictMapper;
import com.capgemini.scaffold.mapper.InternMapper;
import com.capgemini.scaffold.mapper.UserMapper;
import com.capgemini.scaffold.service.DictService;
import com.capgemini.scaffold.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public  class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements DictService {

    @Resource
    private DictMapper dictMapper;
    @Resource
    private InternMapper internMapper;



    @Override
    public Map<String, List<Dict>> getDict(List<String> dictTypeList){
        LambdaQueryWrapper<Dict> qw = Wrappers.lambdaQuery();
        //引用
        qw.in(Dict::getType,dictTypeList);
        List<Dict> dictList = dictMapper.selectList(qw);
        Map<String,List<Dict>> collect = dictList.stream().collect(Collectors.groupingBy(Dict::getType));
        return collect;

    }

    @Override
    public List<Dict> queryJobCount() {
        List<Dict> list = dictMapper.queryInternJob();
        List<Dict> name = queryInternJobName();
        for (Dict dict : name) {
            System.out.println(dict.getName());
        }
        for (Dict dict : list) {
            System.out.println(dict);
        }
        return list;
    }

    @Override
    public List<Dict> queryInternJobName() {

        return dictMapper.queryInternJobName();
    }

    @Override
    public Integer queryManCount() {
        return internMapper.queryManCount();
    }

    /**
     * 首页
     * 大哥
     */
    @Override
    public HomePage querySexCount() {
        return firstPage();
    }

    @Override
    public Integer queryFrontEndCount() {
        return dictMapper.queryFrontEndCount();
    }

    @Override
    public Integer queryPMCount() {
        return dictMapper.queryPMCount();
    }

    @Override
    public Integer queryBACount() {
        return dictMapper.queryBACount();
    }

    @Override
    public Integer queryBlackEndCount() {
        return dictMapper.queryBlackEndCount();
    }

    @Override
    public Integer queryTutorBlackEndCount() {
        return dictMapper.queryTutorBlackEndCount();
    }

    @Override
    public Integer queryTutorFrontEndCount() {
        return dictMapper.queryTutorFrontEndCount();
    }

    @Override
    public Integer queryTutorPMCount() {
        return dictMapper.queryTutorPMCount();
    }

    @Override
    public Integer queryTutorBACount() {
        return dictMapper.queryTutorBACount();
    }

        public HomePage firstPage(){
            Integer manCount = queryManCount();
            Integer count = internMapper.queryNvCount();
            Integer frontEndCount = queryFrontEndCount();
            Integer pmCount = queryPMCount();
            Integer blackEndCount = queryBlackEndCount();
            Integer tutorBlackEndCount = queryTutorBlackEndCount();
            Integer tutorBACount = queryTutorBACount();
            Integer tutorPMCount = queryTutorPMCount();
            Integer tutorFrontEndCount = queryTutorFrontEndCount();
            HomePage homePage = new HomePage();
            Integer baCount = queryBACount();
            homePage.setFemaleCount(count);
            homePage.setManCount(manCount);
            homePage.setBlackEndCount(blackEndCount);
            homePage.setFrontEndCount(frontEndCount);
            homePage.setBACount(baCount);
            homePage.setPMCount(pmCount);
            homePage.setTutorBlackEndCount(tutorBlackEndCount);
            homePage.setTutorFrontEndCount(tutorFrontEndCount);
            homePage.setTutorBACount(tutorBACount);
            homePage.setTutorPMCount(tutorPMCount);
            return homePage;
        }

}
  /*  @Override
    public List<Dict> getDict(String dictType) {

        LambdaQueryWrapper<Dict> qw = Wrappers.lambdaQuery();
        qw.eq(Dict::getType,dictType);
        return dictMapper.selectList(qw);
    }*/